<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<div class="modal" id="deleteModal">
	<input type="hidden" name="id" id="id">
	<div class="modal-dialog">
		
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close" onclick="closeBankCardDialog()">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title">友情提示</h4>
			</div>
			<div class="modal-body">
							<h4>是否确认删除？</h4>
			</div>
			<div class="modal-footer">
				 <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				  <button type="button" class="btn btn-primary" id="deleteCard">确认</button>
			</div>
		</div>
		<!-- /.modal-content -->
	</div>
	<!-- /.modal-dialog -->
</div>
<!-- /.modal -->

<div class="modal" id="isDefaultModal">
	<input type="hidden" name="id" id="id">
	<div class="modal-dialog">
		<!-- 用户编号 bankChannelNo -->
		<input type="hidden" name="userNo" id="userNo">
		<!-- 账户编号 bankChannelNo -->
		<input type="hidden" name="bankAccountNo" id="bankAccountNo">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close" onclick="closeBankCardDialog()">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title">友情提示</h4>
			</div>
			<div class="modal-body">
							<h4>是否确认设置为默认？</h4>
			</div>
			<div class="modal-footer">
				 <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				  <button type="button" class="btn btn-primary" id="defaultCard">确认</button>
			</div>
		</div>
		<!-- /.modal-content -->
	</div>
	<!-- /.modal-dialog -->
</div>
<!-- /.modal -->



<script>
function deleteCardBtn(data){
	$('#deleteModal #id').val(data);
	$('#deleteModal').modal('show');
}

function defaultCardBtn(data){
	$('#isDefaultModal #id').val(data);
	$('#isDefaultModal').modal('show');
}

$('#deleteModal #deleteCard').on("click",function(){
	var id = $('#deleteModel #id').val();
	deleteCard(id);
});

$('#isDefaultModal #defaultCard').on("click",function(){
	var id = $('#isDefaultModal #id').val();
	defaultCard(id);
});


function deleteCard(data){
	var id = data;
	$.ajax({
		type : "POST",
		data : {
			"id" : id
		},
		dataType : "json",
		url : "${baseURL }/merchant/bank/delete",
		success : function(result){
			if(result.code == '0'){
				$('#deleteModal').modal('hide');
				$('#deleteModel #id').val("");
				/* 刷新页面 */
				searchCard();
			}else{
				$('#deleteModal').modal('hide');
				alertMsg(result.msg,"danger");
			}
		},
		error : function(){
			alertMsg("系统异常！","danger");
		}
	});
}

function defaultCard(data){
	var id = data;
	$.ajax({
		type : "POST",
		data : {
			"id" : id,
		},
		dataType : "json",
		url : "${baseURL }/merchant/bank/isDefault",
		success : function(result){
			if(result.code == '0'){
				$('#isDefaultModal').modal('hide');
				$('#isDeleteModel #id').val("");
				/* 刷新页面 */
				var oTableRemit = null;
				searchCard();
			}else{
				$('#isDefaultModal').modal('hide');
				alertMsg(result.msg,"danger");
			}
		},
		error : function(){
			alertMsg("系统异常！","danger");
		}
	});
}


</script>